/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


/*
import junit.framework.Assert;
import junit.framework.TestCase;
*/

import static org.junit.Assert.*;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Random;

import junit.framework.TestCase;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;


/**
 * Performs Validation Test for url validations.
 * 
 * By: Matt Mallon and Janet Putnam
 * CS362 - Final Project
 *
 * @version $Revision: 1128446 $ $Date: 2011-05-27 13:29:27 -0700 (Fri, 27 May 2011) $
 */
public class UrlValidatorTest extends TestCase {

   private boolean printStatus = false;
   private boolean printIndex = false;//print index that indicates current scheme,host,port,path, query test were using.
   
   public UrlValidatorTest(String testName) {
      super(testName);
   }

   
   
   public void testManualTest()
   {
	   boolean expected, actual;
	   
	   UrlValidator urlVal = new UrlValidator();
	   
	   //STARTING POINT: BASIC URL
	   //test case 1 - basic url
	   actual = urlVal.isValid("http://www.testing.com");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.com");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.testing.com");
	   }
	   
	   /* SCHEMA
	    * 
	    *  
	    *  */
	   
	   //test case 2 - too many t's in http
	   actual = urlVal.isValid("htttp://www.test.edu");
	   expected = false;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for htttp://www.test.edu");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for htttp://www.test.edu");
	   }
	   
	   //test case 3 - https
	   actual = urlVal.isValid("https://www.google.com");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for https://www.google.com");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for https://www.google.com");
	   }
	   
	   //test case 4 - ftp
	   actual = urlVal.isValid("ftp://0.0.0.0/test/testing");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for ftp://0.0.0.0/test/testing");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for ftp://0.0.0.0/test/testing");
	   }
	   
	   //test case 5 - sftp
	   actual = urlVal.isValid("sftp://www.google.com");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for sftp://www.google.com");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for sftp://www.google.com");
	   }
	     
	   /* DOMAIN 
	    * 
	    * 
	    * */
	   
	   //test case 6 -- url with country extension .au at end
	   actual = urlVal.isValid("http://www.testing.au");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.au");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.testing.au");
	   }
	   
	   //test case 7 - url with country extension (Mongolia)
	   actual = urlVal.isValid("http://www.testing.mn");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.mn");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.testing.mn");
	   }
	   
	   //test case 8 - .org
	   actual = urlVal.isValid("http://www.testing.org");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.org");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.testing.org");
	   }
	   
	   //test case 9 - .edu
	   actual = urlVal.isValid("http://www.testing.edu");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.edu");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.testing.edu");
	   }
	   
	   //test case 10 - .xyz at end -- is the program just checking for length here?
	   actual = urlVal.isValid("http://test.xyz");
	   expected = false;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://test.xyz");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://test.xyz");
	   }
	   
	   //test case 11 -- capitalized .COM
	   actual = urlVal.isValid("http://www.testing.COM");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.COM");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.testing.COM");
	   }
	   
	   /* SITE NAME AND PATH 
	    * 
	    * 
	    * */
	   
	   //test case 12 - number in url
	   actual = urlVal.isValid("http://www.w3schools.com");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.w3schools.com");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.w3schools.com");
	   }
	   
	   //test case 13 -- capitalized letters in site name
	   actual = urlVal.isValid("http://www.TESTING.com");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.TESTING.com");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.TESTING.com");
	   }
	   
	   //test case 14 - php ending
	   actual = urlVal.isValid("http://facebook.com/one/two/three.php");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://facebook.com/one/two/three.php");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://facebook.com/one/two/three.php");
	   }
	   
	   //test case 15 -- html at end
	   actual = urlVal.isValid("http://www.testing.com/testing.html");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.com/testing.html");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.testing.com/testing.html");
	   }
	   
	   //test case 16 - multiple slashes in path
	   actual = urlVal.isValid("http://test.com///testing");
	   expected = false;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://test.com///testing");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://test.com///testing");
	   }	   
	   
	   
	   /* IP ADDRESSES 
	    * 
	    * 
	    * */	  
	   
	   //test case 17 - valid IP address 1
	   actual = urlVal.isValid("http://74.125.28.104/");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://74.125.28.104/");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://74.125.28.104/");
	   }
	   
	   //test case 18 - invalid IP address with number > 255
	   actual = urlVal.isValid("http://74.325.28.104/");
	   expected = false;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://74.325.28.104/");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://74.325.28.104/");
	   }
	   
	   //test case 19 - invalid IP address with negative number
	   actual = urlVal.isValid("http://74.-325.28.104/");
	   expected = false;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://74.-325.28.104/");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://74.-325.28.104/");
	   }
	   
	   /* QUERIES
	    * 
	    * 
	    * */
	   
	   //test case 20 - valid query
	   actual = urlVal.isValid("http://www.test.com/test?testquery");
	   expected = false;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.test.com/test?testquery");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.test.com/test?testquery");
	   }

   }
   
   
   public void testYourFirstPartition()
   {	   
	 //test suffix (domains) for valid/not valid
	   //www.iana.org lists the following as valid suffixes:
	 String[] suffixes = {"AC", "ACADEMY", "ACCOUNTANTS", "ACTOR", "AD", "AE", "AERO", "AF", "AG", "AGENCY", "AI", "AIRFORCE", "AL", "AM", "AN", "AO", "AQ", "AR", "ARCHI", "ARPA", "AS", "ASIA", "ASSOCIATES", "AT", "AU", "AUDIO", "AUTOS", "AW", "AX", "AXA", "AZ", "BA", "BAR", "BARGAINS", "BAYERN", "BB", "BD", "BE", "BEER", "BERLIN", "BEST", "BF", "BG", "BH", "BI", "BID", "BIKE", "BIZ", "BJ", "BLACK", "BLACKFRIDAY", "BLUE", "BM", "BN", "BO", "BOUTIQUE", "BR", "BS", "BT", "BUILD", "BUILDERS", "BUZZ", "BV", "BW", "BY", "BZ", "CA", "CAB", "CAMERA", "CAMP", "CAPITAL", "CARDS", "CARE", "CAREER", "CAREERS", "CASH", "CAT", "CATERING", "CC", "CD", "CENTER", "CEO", "CF", "CG", "CH", "CHEAP", "CHRISTMAS", "CHURCH", "CI", "CITIC", "CK", "CL", "CLAIMS", "CLEANING", "CLINIC", "CLOTHING", "CLUB", "CM", "CN", "CO", "CODES", "COFFEE", "COLLEGE", "COLOGNE", "COM", "COMMUNITY", "COMPANY", "COMPUTER", "CONDOS", "CONSTRUCTION", "CONSULTING", "CONTRACTORS", "COOKING", "COOL", "COOP", "COUNTRY", "CR", "CREDIT", "CREDITCARD", "CRUISES", "CU", "CV", "CW", "CX", "CY", "CZ", "DANCE", "DATING", "DE", "DEGREE", "DEMOCRAT", "DENTAL", "DESI", "DIAMONDS", "DIGITAL", "DIRECTORY", "DISCOUNT", "DJ", "DK", "DM", "DNP", "DO", "DOMAINS", "DZ", "EC", "EDU", "EDUCATION", "EE", "EG", "EMAIL", "ENGINEERING", "ENTERPRISES", "EQUIPMENT", "ER", "ES", "ESTATE", "ET", "EU", "EUS", "EVENTS", "EXCHANGE", "EXPERT", "EXPOSED", "FAIL", "FARM", "FEEDBACK", "FI", "FINANCE", "FINANCIAL", "FISH", "FISHING", "FITNESS", "FJ", "FK", "FLIGHTS", "FLORIST", "FM", "FO", "FOO", "FOUNDATION", "FR", "FROGANS", "FUND", "FURNITURE", "FUTBOL", "GA", "GAL", "GALLERY", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GIFT", "GL", "GLASS", "GLOBO", "GM", "GMO", "GN", "GOP", "GOV", "GP", "GQ", "GR", "GRAPHICS", "GRATIS", "GRIPE", "GS", "GT", "GU", "GUIDE", "GUITARS", "GURU", "GW", "GY", "HAUS", "HIPHOP", "HK", "HM", "HN", "HOLDINGS", "HOLIDAY", "HOMES", "HORSE", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IMMOBILIEN", "IN", "INDUSTRIES", "INFO", "INK", "INSTITUTE", "INSURE", "INT", "INTERNATIONAL", "INVESTMENTS", "IQ", "IR", "IS", "IT", "JE", "JETZT", "JM", "JO", "JOBS", "JP", "JUEGOS", "KAUFEN", "KE", "KG", "KH", "KI", "KIM", "KITCHEN", "KIWI", "KM", "KN", "KOELN", "KP", "KR", "KRED", "KW", "KY", "KZ", "LA", "LAND", "LB", "LC", "LEASE", "LI", "LIFE", "LIGHTING", "LIMITED", "LIMO", "LINK", "LK", "LOANS", "LONDON", "LR", "LS", "LT", "LU", "LUXE", "LUXURY", "LV", "LY", "MA", "MAISON", "MANAGEMENT", "MANGO", "MARKETING", "MC", "MD", "ME", "MEDIA", "MEET", "MENU", "MG", "MH", "MIAMI", "MIL", "MK", "ML", "MM", "MN", "MO", "MOBI", "MODA", "MOE", "MONASH", "MOSCOW", "MOTORCYCLES", "MP", "MQ", "MR", "MS", "MT", "MU", "MUSEUM", "MV", "MW", "MX", "MY", "MZ", "NA", "NAGOYA", "NAME", "NC", "NE", "NET", "NEUSTAR", "NF", "NG", "NI", "NINJA", "NL", "NO", "NP", "NR", "NU", "NYC", "NZ", "OKINAWA", "OM", "ONL", "ORG", "PA", "PARIS", "PARTNERS", "PARTS", "PE", "PF", "PG", "PH", "PHOTO", "PHOTOGRAPHY", "PHOTOS", "PICS", "PICTURES", "PINK", "PK", "PL", "PLUMBING", "PM", "PN", "POST", "PR", "PRO", "PRODUCTIONS", "PROPERTIES", "PS", "PT", "PUB", "PW", "PY", "QA", "QPON", "QUEBEC", "RE", "RECIPES", "RED", "REISE", "REISEN", "REN", "RENTALS", "REPAIR", "REPORT", "REST", "REVIEWS", "RICH", "RIO", "RO", "ROCKS", "RODEO", "RS", "RU", "RUHR", "RW", "RYUKYU", "SA", "SAARLAND", "SB", "SC", "SCHULE", "SD", "SE", "SERVICES", "SEXY", "SG", "SH", "SHIKSHA", "SHOES", "SI", "SINGLES", "SJ", "SK", "SL", "SM", "SN", "SO", "SOCIAL", "SOHU", "SOLAR", "SOLUTIONS", "SOY", "SPACE", "SR", "ST", "SU", "SUPPLIES", "SUPPLY", "SUPPORT", "SURGERY", "SV", "SX", "SY", "SYSTEMS", "SZ", "TATTOO", "TAX", "TC", "TD", "TECHNOLOGY", "TEL", "TF", "TG", "TH", "TIENDA", "TIPS", "TJ", "TK", "TL", "TM", "TN", "TO", "TODAY", "TOKYO", "TOOLS", "TOWN", "TOYS", "TP", "TR", "TRADE", "TRAINING", "TRAVEL", "TT", "TV", "TW", "TZ", "UA", "UG", "UK", "UNIVERSITY", "UNO", "US", "UY", "UZ", "VA", "VACATIONS", "VC", "VE", "VEGAS", "VENTURES", "VERSICHERUNG", "VG", "VI", "VIAJES", "VILLAS", "VISION", "VN", "VODKA", "VOTE", "VOTING", "VOTO", "VOYAGE", "VU", "WANG", "WATCH", "WEBCAM", "WEBSITE", "WED", "WF", "WIEN", "WIKI", "WORKS", "WS", "WTC", "WTF", "XN--3BST00M", "XN--3DS443G", "XN--3E0B707E", "XN--45BRJ9C", "XN--4GBRIM", "XN--55QW42G", "XN--55QX5D", "XN--6FRZ82G", "XN--6QQ986B3XL", "XN--80ADXHKS", "XN--80AO21A", "XN--80ASEHDB", "XN--80ASWG", "XN--90A3AC", "XN--C1AVG", "XN--CG4BKI", "XN--CLCHC0EA0B2G2A9GCD", "XN--CZR694B", "XN--CZRU2D", "XN--D1ACJ3B", "XN--FIQ228C5HS", "XN--FIQ64B", "XN--FIQS8S", "XN--FIQZ9S", "XN--FPCRJ9C3D", "XN--FZC2C9E2C", "XN--GECRJ9C", "XN--H2BRJ9C", "XN--I1B6B1A6A2E", "XN--IO0A7I", "XN--J1AMH", "XN--J6W193G", "XN--KPRW13D", "XN--KPRY57D", "XN--L1ACC", "XN--LGBBAT1AD8J", "XN--MGB9AWBF", "XN--MGBA3A4F16A", "XN--MGBAAM7A8H", "XN--MGBAB2BD", "XN--MGBAYH7GPA", "XN--MGBBH1A71E", "XN--MGBC0A9AZCG", "XN--MGBERP4A5D4AR", "XN--MGBX4CD0AB", "XN--NGBC5AZD", "XN--NQV7F", "XN--NQV7FS00EMA", "XN--O3CW4H", "XN--OGBPF8FL", "XN--P1AI", "XN--PGBS0DH", "XN--Q9JYB4C", "XN--RHQV96G", "XN--S9BRJ9C", "XN--SES554G", "XN--UNUP4Y", "XN--WGBH1C", "XN--WGBL6A", "XN--XKC2AL3HYE2A", "XN--XKC2DL3A5EE0H", "XN--YFRO4I67O", "XN--YGBI2AMMX", "XN--ZFR164B", "XXX", "XYZ", "YACHTS", "YE", "YOKOHAMA", "YT", "ZA", "ZM", "ZONE", "ZW"}; 
	 int x = suffixes.length;
	 String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-";
	 boolean expected, result;
	 UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);

	 //number of tests
	 for (int i = 0; i < 10000; i++)
	 {
		 //length of string
		 for (int j = 2; j <23; j++)
		 {
			 char domain[] = new char[j];
			 String website = "http://www.test.";
			 for(int k = 0; k<j; k++)
			 {
				 Random rand = new Random();
				 domain[k] = characters.charAt(rand.nextInt(characters.length()));
			 }
			 
			 String domain1 = new String(domain);
			 website = website.concat(domain1);
			 
			 if (Arrays.asList(suffixes).contains(domain1))
			 {
				 expected = true;
			 }
			 else
			 {
				 expected = false;
			 }
			 result = urlVal.isValid(website);
			 if (result == expected) 
			 {
				   //only failures are printed -- this can be uncommented if needed
				   //System.out.printf("Success: Domain %s results were as expected.\n", domain1);
			 }
			 else
			 {
				   System.out.printf("Failure: Domain %s results were not as expected.\n", domain1);
			 }
		 }	 
	  }   
   }
   
   public void testYourSecondPartition(){	   
	 //partition the number of slashes in path -- testing.com/test /test //test .comtest (no slash)	   
	   boolean expected, actual;
	   UrlValidator urlVal = new UrlValidator();
	   
	   //valid -- 1 slash in path
	   actual = urlVal.isValid("http://www.testing.com/test");
	   expected = true;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.com/test");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.testing.com/test");
	   }
	   
	   //invalid -- 2 slashes in path
	   actual = urlVal.isValid("http://www.testing.com//test");
	   expected = false;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.com//test");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.testing.com//test");
	   }
	   
	   //invalid -- 3 slashes in path
	   actual = urlVal.isValid("http://www.testing.com///test");
	   expected = false;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.com///test");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http:///www.testing.com//test");
	   }
	   
	   //invalid -- 0 slashes in path
	   actual = urlVal.isValid("http://www.testing.comtest");
	   expected = false;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.comtest");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.testing.comtest");
	   }
	   
	   //invalid -- 2 slashes at end
	   actual = urlVal.isValid("http://www.testing.com/test//");
	   expected = false;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.com/test//");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.testing.com/test//");
	   }
	   
	 //invalid -- 2 slashes on first directory, 1 on second
	   actual = urlVal.isValid("http://www.testing.com//test/testing");
	   expected = false;
	   if (actual == expected) {
		   System.out.println("Success: actual is same as expected for http://www.testing.com//test/testing");
	   } else {
		   System.out.println("Failure: actual is not the same as expected for http://www.testing.com//test/testing");
	   }
	   
   }
   
   public void testIsValid()
   {
	   //possible parts of a url to combine, using a ResultPair
	   ResultPair[] schemes = {new ResultPair("http://", true),
			   				  new ResultPair("https://", true),
			   				  new ResultPair("httpr://", false),
			   				  new ResultPair("http:///", false),
			   				  new ResultPair("httttttp://", false)
	   };
	   
	   ResultPair[] authorities = {new ResultPair("www.wikipedia.org", true),
			   						new ResultPair("www.sourceforge.net", true),
			   						new ResultPair("www.incorrect.xyz", false),
			   						new ResultPair("$%^*", false)
	   };
	   
	   ResultPair[] paths = {new ResultPair("/test", true),
			   				new ResultPair("///test", false),
			   				new ResultPair("/test//", false),
			   				new ResultPair("/test/testing/tester/test", true)   
	   };
	   
	   ResultPair[] queries = {new ResultPair("?name=test", true),
			   				   new ResultPair("???name=test", true),
			   				   new ResultPair("?name=test&secondtest=test", true)
			   
	   };
	   
	   Random rand = new Random();
	   int max, randomNum;
	   int min = 0;
	   boolean expected, actual, schemeValid, authorityValid, pathValid, queryValid;
	   String sitename;
	   
	   UrlValidator urlVal = new UrlValidator();
	   
	   for(int i = 0;i<10000;i++)
	   {
		   min = 0;
		   
		   //schemes
		   max = schemes.length;
		   randomNum = rand.nextInt(max - min) + min;
		   String scheme = schemes[randomNum].item;
		   schemeValid = schemes[randomNum].valid;
		   
		   //authorities
		   max = authorities.length;
		   randomNum = rand.nextInt(max - min) + min;
		   String authority = authorities[randomNum].item;
		   authorityValid = authorities[randomNum].valid;
		   
		   //path
		   max = paths.length;
		   randomNum = rand.nextInt(max - min) + min;
		   String path = paths[randomNum].item;
		   pathValid = paths[randomNum].valid;
		   
		   //query
		   max = queries.length;
		   randomNum = rand.nextInt(max - min) + min;
		   String query = queries[randomNum].item;
		   queryValid = queries[randomNum].valid;
		   
		   //on even numbers, add a query, and on odd numbers, leave it off
		   if (i % 2 == 0) {
			   sitename = scheme + authority + path + query;
			   if (schemeValid == false || authorityValid == false || pathValid == false || queryValid == false) {
				   expected = false;
			   } else {
				   expected = true;
			   }
		   } else {
			   sitename = scheme + authority + path;
			   if (schemeValid == false || authorityValid == false || pathValid == false) {
				   expected = false;
			   } else {
				   expected = true;
			   }
		   }
		   
		   actual = urlVal.isValid(sitename);
		   if (actual == expected) {
			   //only failures are printed -- this can be uncommented if needed
			   //System.out.println("Success: actual is same as expected for " + sitename);
		   } else {
			   System.out.println("Failure: actual is not the same as expected for " + sitename);
		   }
		   
	   }
   }
   
   public void testAnyOtherUnitTest()
   {
	   
	   
	   UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);
	   String address = "http://";
	   String dash = "/";
	   String dot =".";
	   int min = 0;
	   int max = 999;
	   boolean expected, actual;
	   
	   for (int z = 0; z < 10000; z++)
	   {
		   expected = true;
		   String octet = "";
		   String website = "";
		   
		   for (int x = 0; x < 4; x ++)
		   {
			   Random rand = new Random();
			   int randomNum = rand.nextInt(max - min) + min;
			   if (randomNum > 255)
			   {
				   expected = false;
			   }
			   
			   octet = octet.concat(Integer.toString(randomNum));
			   if (x != 3)
			   {
				   octet = octet.concat(dot);
			   }
			   else
			   {
				   octet = octet.concat(dash);
			   }
		   }
		   
		   website = website.concat(address);
		   website = website.concat(octet);
	   
		   //System.out.println(website);
		   
		   actual = urlVal.isValid(website);
		   if (actual == expected)
		   {
			   //System.out.println("Success: actual is same as expected for " + website);
		   }
		   else
		   {
			   System.out.println("Failure: actual is different than expected for " + website);
			   if (expected == false)
			   {
				   System.out.println("Octet value out of range (>255)");
			   }
		   }
	   
	   }
	   
	   
   }

}
